#ifndef PTHREAD_H
#define PTHREAD_H

#include "common.h"
#include "mqtt.h"

extern MsgQueue queue;
extern MQTTClient pub_client;
extern MQTTClient sub_client;
extern void* shm_addr;
extern int g_quit;


void* read_shm_thread(void* arg);      // 读共享内存+序列化线程
void* mqtt_publish_thread(void* arg);  // MQTT发布线程
void* mqtt_subscribe_thread(void* arg); // MQTT订阅线程
void* queue_thread(void* arg);         // 消息队列管理线程
int msgarrvd(void *context, char *topicName, int topicLen, MQTTClient_message *message);

// 线程创建函数（统一启动所有线程）
int create_device_threads(pthread_t* t1, pthread_t* t2, pthread_t* t3, pthread_t* t4);

#endif